package com.yutel.http.HttpServer;

public class ParameterUtil {
	private static StringBuffer res = new StringBuffer();

	public static void main(String[] args) {

		System.out.println(getServerInfo());
	}

	public static String getServerInfo() {
		return getServerInfo("58:55:CA:1A:E2:88", "119", "AppleTV2,1", "1.0",
				"120.2");
	}

	public static String getServerInfo(String deviceid, String features,
			String model, String protovers, String srcvers) {
		return String.format(serverInfo(), deviceid, features, model,
				protovers, srcvers);
	}

	private static String serverInfo() {
		res.setLength(0);
		res.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
		res.append("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\"");
		res.append(" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\r\n");
		res.append("<plist version=\"1.0\">\r\n");
		res.append(" <dict>\r\n");
		res.append("  <key>deviceid</key>\r\n");
		res.append("  <string>%1$s</string>\r\n");
		res.append("  <key>features</key>\r\n");
		res.append("  <integer>%2$S</integer>\r\n");
		res.append("  <key>model</key>\r\n");
		res.append("  <string>%3$s</string>\r\n");
		res.append("  <key>protovers</key>\r\n");
		res.append("  <string>%4$s</string>\r\n");
		res.append("  <key>srcvers</key>\r\n");
		res.append("  <string>%5$s</string>\r\n");
		res.append(" </dict>\r\n");
		res.append("</plist>\r\n");
		return res.toString();
	}

	public static String int2ip(int ipInt) {
		StringBuilder sb = new StringBuilder();
		sb.append(ipInt & 0xFF).append(".");
		sb.append((ipInt >> 8) & 0xFF).append(".");
		sb.append((ipInt >> 16) & 0xFF).append(".");
		sb.append((ipInt >> 24) & 0xFF);
		return sb.toString();
	}
}
